<template>
	<body-wrap isFlex>
		<view class="topSearch">
			<my-search v-model="kwd" @confirm='doSearch'/>
		</view>
		<teacher-list :lists="teacherlist || []"/>
		<empty v-if="teacherlist && teacherlist.length==0"/>
	</body-wrap>
</template>

<script>
	import {defineComponent,reactive,toRefs,onMounted,getCurrentInstance,computed} from 'vue'
	import {onLoad,onShow} from '@dcloudio/uni-app'
	import { useStore } from 'vuex'
	import bodyWrap from "@/components/bodyWrap/index.vue"
	import mySearch from "@/components/mySearch/index.vue"
	import teacherList from "@/components/teacherList/index.vue"
	import {getUserList} from "@/api/consult.js"
	import empty from "@/components/empty/index.vue"
	export default defineComponent({
		components:{
			bodyWrap,
			mySearch,
			teacherList,
			empty
		},
		props:{
		
		},
		setup(props,context) {
			const store = useStore()
			const {proxy} = getCurrentInstance()
			
			const state = reactive({
				kwd:'',
				pageIndex:1,
				pageSize:20,
				teacherlist:''
			})
			
			onLoad(options=>{
				if(options && options.keyword){
					state.kwd = options.keyword
				}
				getTcList()
			})
			
			onMounted(()=>{
				
			})
			
			const getTcList = async ()=>{
				const res = await getUserList({
					type:1,
					pageIndex:state.pageIndex,
					pageSize:state.pageSize,
					from:'EJConsult',
					keywords:state.kwd
				})
				state.teacherlist = res.data.data || []
			}
			
			const doSearch = ()=>{
				getTcList()
			}
			
			return {
				...toRefs(state),
				doSearch
			}
		}
	})
</script>

<style lang="scss" scoped>
	.topSearch{
		padding: 20rpx;
	}
</style>
